package com.ljh.order.orderservice.controller;

import com.ljh.order.orderservice.model.Order;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author: Themberfue
 * @date: 2025/4/29 20:21
 * @description:
 */
@RequestMapping("/order")
@RestController
public class OrderController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @RequestMapping("/create")
    public String create() {
        Order order = Order.builder()
                        .id(UUID.randomUUID().toString())
                        .name("订单")
                        .build();
        rabbitTemplate.convertAndSend("", "order.create", "订单信息发送成功：" + order);
        return "订单信息发送成功";
    }
}
